Skip to content

LCORE-5601: improved unit tests - #3302

Open
tisnik wants to merge 4 commits into
lightspeed-core:mainfrom
tisnik:lcore-5601-improved-unit-tests
Open

tisnik wants to merge 4 commits into
lightspeed-core:mainfrom
tisnik:lcore-5601-improved-unit-tests

Conversation

@tisnik

@tisnik tisnik commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

LCORE-5601: improved unit tests

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library [pyproject.toml + uv.lock]
  • Bump-up dependent library [requirements.*.txt for Konflux]
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: Codex

Related Tickets & Documents

  • Related Issue #LCORE-5601

Summary by CodeRabbit

  • Tests
    • Expanded coverage for vector-store creation settings, rate-limit responses, and upload size limits.
    • Added anonymization tests for case normalization, match precedence, allow-listed spelling, and configured deny-list entities.
    • Added checks for image prompt settings and input preservation, plus conversation compaction call sequencing.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds and updates unit tests for vector-store endpoints, PII anonymization, image-prompt inputs, and conversation compaction. It does not change production code.

Changes

Vector-store endpoint tests

Layer / File(s) Summary
Vector-store endpoint coverage
tests/unit/app/endpoints/test_vector_stores.py
Tests assert that creation passes provider and embedding values in extra_body. They cover 429 errors from both clients and verify that oversized streams are rejected without being read or uploaded. The upload-stream comment now refers to httpx2.

PII anonymizer tests

Layer / File(s) Summary
Anonymizer behavior coverage
tests/unit/pii_redaction_engine/test_anonymizer.py
A mocked fixture supports tests for text recasing, overlapping-match precedence, conditions that skip a second analyzer call, and deny-list recognition.

Compacted input media tests

Layer / File(s) Summary
Image prompt input coverage
tests/unit/pydantic_ai_lightspeed/ogx/test_compacted_input_media.py
The image-prompt element type now includes ImageUrl. The test checks extra_body and confirms the original settings input remains unchanged.

Conversation compaction redaction tests

Layer / File(s) Summary
Summarizer call assertions
tests/unit/utils/test_conversation_compaction_redaction.py
The test checks that summarize_chunk was awaited before inspecting its arguments.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Other

Suggested reviewers: max-svistunov, jslyoon

Merge Risk: Minimal · up to a16e1

This change only adds and adjusts unit tests, with no production behavior changes. No merge-blocking concerns were identified.

Pre-merge checks: Passed 6

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "LCORE-5601: improved unit tests" matches the changeset, which only adds and refines unit tests across four test files. It is broad and does not name the main behaviours covered, such as the…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Performance And Algorithmic Complexity Passed The check is BLOCKING for meaningful performance regressions: O(n^2)+ algorithms, N+1 patterns, expensive work in loops, unbounded growth, and missing pagination. The diff inventory (`git diff --name-…
Security And Secret Handling Passed PR #3302 (lightspeed-core/lightspeed-stack, author tisnik per the provider record) changes only four unit-test files: tests/unit/app/endpoints/test_vector_stores.py, tests/unit/pii_redaction_engine/te…
Full details: Title check

Explanation

The title "LCORE-5601: improved unit tests" matches the changeset, which only adds and refines unit tests across four test files. It is broad and does not name the main behaviours covered, such as the 429 rate-limit mapping, the 413 upload size check, or the anonymizer tests. It is not vague enough to fail, and the ticket ID gives traceability.

Full details: Performance And Algorithmic Complexity

Explanation

The check is BLOCKING for meaningful performance regressions: O(n^2)+ algorithms, N+1 patterns, expensive work in loops, unbounded growth, and missing pagination. The diff inventory (git diff --name-status on the review range) lists four modified files, all under tests/unit/: - tests/unit/app/endpoints/test_vector_stores.py - tests/unit/pii_redaction_engine/test_anonymizer.py - tests/unit/pydantic_ai_lightspeed/ogx/test_compacted_input_media.py - tests/unit/utils/test_conversation_compaction_redaction.py No production code, caches, buffers, or endpoints change. I read the test_vector_stores.py patch. It adds parametrized tests with small fixed inputs, a 5-byte BytesIO stream, and mocked clients. None of these introduces a runtime performance concern. The remaining test diffs are small assertion and annotation changes. No finding under the stated criteria is introduced.

Full details: Security And Secret Handling

Explanation

PR #3302 (lightspeed-core/lightspeed-stack, author tisnik per the provider record) changes only four unit-test files: tests/unit/app/endpoints/test_vector_stores.py, tests/unit/pii_redaction_engine/test_anonymizer.py, tests/unit/pydantic_ai_lightspeed/ogx/test_compacted_input_media.py, and tests/unit/utils/test_conversation_compaction_redaction.py. No production source, endpoint, or configuration file changed. Checked against the five failure conditions: 1. Secrets or tokens: no logged or hardcoded credentials. Values such as "test-provider", "test-embedding", and "Rate limit exceeded" are fixtures, not secrets. 2. Missing auth on endpoints: no endpoint or route changed. The new tests call the existing endpoints with the test-only mock_authorization_resolvers helper. 3. Injection: no SQL, shell, or path handling was added. The oversized-upload test uses an in-memory io.BytesIO stream. 4. Sensitive data leakage: no API response, WebSocket message, or log output was changed. 5. K8s or RH secrets: no manifests or secret objects were added or changed. The new tests check existing security behavior, including the 413 rejection of oversized uploads and the 429 mapping of rate-limit errors. They do not weaken any control.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Simplify code

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between cbd7d6f and a16e103.

Files selected for processing: 4

  • tests/unit/app/endpoints/test_vector_stores.py
  • tests/unit/pii_redaction_engine/test_anonymizer.py
  • tests/unit/pydantic_ai_lightspeed/ogx/test_compacted_input_media.py
  • tests/unit/utils/test_conversation_compaction_redaction.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 22

  • GitHub Check: E2E: library / ci / mcp
  • GitHub Check: E2E: library / ci / shields
  • GitHub Check: E2E: library / ci / other
  • GitHub Check: E2E: library / ci / rbac
  • GitHub Check: E2E: server / ci / authorized
  • GitHub Check: E2E: library / ci / default
  • GitHub Check: E2E: library / ci / skills
  • GitHub Check: E2E: library / ci / authorized
  • GitHub Check: E2E: server / ci / skills
  • GitHub Check: E2E: server / ci / other
  • GitHub Check: E2E: server / ci / default
  • GitHub Check: E2E: server / ci / shields
  • GitHub Check: E2E: server / ci / tls
  • GitHub Check: E2E: server / ci / rbac
  • GitHub Check: E2E: server / ci / mcp
  • GitHub Check: integration_tests (3.13)
  • GitHub Check: integration_tests (3.14)
  • GitHub Check: integration_tests (3.12)
  • GitHub Check: Pylinter
  • GitHub Check: build-pr
  • GitHub Check: unit_tests (3.12)
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-0-8-on-pull-request
Additional context used

Code guidelines: 2

AGENTS.md — auto-discovered
CLAUDE.md — auto-discovered
Path-based instructions: 4

Source excerpt: **Required**: Use pytest for all unit and integration tests Source excerpt: **Forbidden**: Do not use unittest - pytest is the standard for this project Source excerpt: **Coverage**: Unit tests require 60% coverage, integrat...

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/app/endpoints/test_vector_stores.py
  • tests/unit/pii_redaction_engine/test_anonymizer.py
  • tests/unit/pydantic_ai_lightspeed/ogx/test_compacted_input_media.py
  • tests/unit/utils/test_conversation_compaction_redaction.py
Source excerpt: **Required**: Use pytest for all unit and integration tests Source excerpt: **Forbidden**: Do not use unittest - pytest is the standard for this project Source excerpt: **Mocking**: `pytest-mock` for AsyncMock objects

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/unit/app/endpoints/test_vector_stores.py
  • tests/unit/pii_redaction_engine/test_anonymizer.py
  • tests/unit/pydantic_ai_lightspeed/ogx/test_compacted_input_media.py
  • tests/unit/utils/test_conversation_compaction_redaction.py
Source excerpt: **Coverage**: Unit tests require 60% coverage, integration 10% Source excerpt: **Async tests**: Use marker `pytest.mark.asyncio`

CodeRabbit inference engine (CLAUDE.md)

Files:

  • tests/unit/app/endpoints/test_vector_stores.py
  • tests/unit/pii_redaction_engine/test_anonymizer.py
  • tests/unit/pydantic_ai_lightspeed/ogx/test_compacted_input_media.py
  • tests/unit/utils/test_conversation_compaction_redaction.py
Source excerpt: **Mocking**: `pytest-mock` for AsyncMock objects Source excerpt: **Async tests**: Use marker `pytest.mark.asyncio`

CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/unit/app/endpoints/test_vector_stores.py
  • tests/unit/pii_redaction_engine/test_anonymizer.py
  • tests/unit/pydantic_ai_lightspeed/ogx/test_compacted_input_media.py
  • tests/unit/utils/test_conversation_compaction_redaction.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant